<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hyperf_mall
 * @contact  hyperf_mall@163.com
 */

namespace App\JsonRpc;

use App\Repository\CartRepository;
use App\Repository\PreOrderRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\CartServiceInterface;

/**
 * @RpcService(name="Orders::PreOrderService", protocol="jsonrpc", server="jsonrpc")
 */
class PreOrderService extends BaseService implements CartServiceInterface
{
    public function init()
    {
        $this->repository = PreOrderRepository::getInstance();
    }

    /**
     * Notes: 获取初始化订单信息
     * Author: Bruce.z
     * DateTime: 2022/7/1 15:35
     * @param array $ids
     * @param int $member_id
     * @param int $coupon_receive_id
     * @param int $address_id
     * @return array
     */
    public function initData(array $ids, int $member_id, int $coupon_receive_id = 0 , int $address_id = 0):array
    {
        return PreOrderRepository::getInstance()->initData($ids, $member_id,$coupon_receive_id, $address_id);
    }

    /**
     * Notes: 立即购买
     * Author: Bruce.z
     * DateTime: 2022/7/21 20:45
     * @param array $param
     * @param int $member_id
     * @return array
     */
    public function initBuy(array $param, int $member_id):array
    {
        return PreOrderRepository::getInstance()->initBuy($param, $member_id);
    }
}
